package com.kexio.config.enums;

/**
 * 配置状态枚举
 * 
 * @author Kexio Team
 * @since 1.0.0
 */
public enum ConfigStatus {
    
    /**
     * 启用
     */
    ENABLED("ENABLED", "启用"),
    
    /**
     * 禁用
     */
    DISABLED("DISABLED", "禁用"),
    
    /**
     * 草稿
     */
    DRAFT("DRAFT", "草稿"),
    
    /**
     * 待审批
     */
    PENDING("PENDING", "待审批"),
    
    /**
     * 已删除
     */
    DELETED("DELETED", "已删除");
    
    private final String code;
    private final String description;
    
    ConfigStatus(String code, String description) {
        this.code = code;
        this.description = description;
    }
    
    public String getCode() {
        return code;
    }
    
    public String getDescription() {
        return description;
    }
    
    /**
     * 根据代码获取枚举
     */
    public static ConfigStatus fromCode(String code) {
        for (ConfigStatus status : values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        throw new IllegalArgumentException("Unknown config status code: " + code);
    }
    
    /**
     * 是否为有效状态
     */
    public boolean isActive() {
        return this == ENABLED;
    }
    
    /**
     * 是否可编辑
     */
    public boolean isEditable() {
        return this == DRAFT || this == PENDING;
    }
    
    /**
     * 是否可删除
     */
    public boolean isDeletable() {
        return this != DELETED;
    }
}
